<?php
class SmartyWe{
     private static $smarty = NULL;
     public function __construct(){
     	//echo "smarty hello";
     	if(!is_null(self::$smarty)) return;
     	$smarty = new Smarty();
     	
        //模版目录
        $smarty->template_dir =  APP_VIEW_PATH . '/' . CONTROLLER . '/';
        //编译目录
        $smarty->compile_dir = APP_COMPILE_PATH;
        //缓存目录
        $smarty->cache_dir = APP_CACHE_PATH;
        //左定界符
        $smarty->left_delimiter = C('LEFT_DELIMITER');
        //右定界符
        $smarty->right_delimiter = C('RIGHT_DELIMITER');
        //是否开启缓存
        $smarty->caching = C('CHCHE_ON');
        //缓存时间
        $smarty->cache_lifetime = C('CACHE_TIME');
        //P($smarty);
     	self::$smarty = $smarty;    	
     }

     protected function fetch($tpl){
        //echo "走了这里的fetch方法";
        self::$smarty->display($tpl,$_SERVER['REQUEST_URI']);
     }

     protected function assign($var,$value){
     	 self::$smarty->assign($var,$value);
     }

     protected function is_cached($tpl=NULL){
           if(!C('SMARTY_ON')) P('请先开启Smarty！！');
           
           $tpl =  $this->get_tpl($tpl); 

           return self::$smarty->is_cached($tpl,$_SERVER['REQUEST_URI']);
     }
}


?>